package com.tang.java.ibator;

import org.apache.commons.io.FileUtils;
import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
import org.apache.ibatis.ibator.api.dom.java.JavaVisibility;
import org.apache.ibatis.ibator.api.dom.java.Method;
import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * @author zhr
 */
public class T1 {
    @Test
    public void t01() throws IOException {
        System.out.println("start");

        TopLevelClass clz = new TopLevelClass(new FullyQualifiedJavaType("T"));
        clz.addImportedType(new FullyQualifiedJavaType("java.util.List"));
//        clz.setSuperClass(new FullyQualifiedJavaType("T"));
        clz.setVisibility(JavaVisibility.PUBLIC);

        Method method = new Method();
        method.setVisibility(JavaVisibility.PUBLIC);
        method.setConstructor(true);
        method.setName(clz.getType().getShortName());
        method.addBodyLine("System.out.println(\"Hello\");");
        clz.addMethod(method);


        System.out.println(clz.getFormattedContent());
        FileUtils.write(new File("D:/tmp/T.java"), clz.getFormattedContent(), "UTF-8");


        System.out.println("end");
    }
}
